<?php
// Route::post('/api/sys_account/list', 'SysAccountController/list');
//Route::get('/api/sys_account/getbyid', 'SysAccountController/getbyid');
//Route::post('/api/sys_account/update', 'SysAccountController/update');
//Route::post('/api/sys_account/add', 'SysAccountController/add');
//Route::get('/api/sys_account/delbyid', 'SysAccountController/delbyid');

namespace app\controller;
use app\BaseController;
use app\model\SysAccount;
use app\utils\CamlHump;
use app\utils\ResposeUtils;
use think\facade\Log;
use think\facade\Request;
class SysAccountController  extends BaseController
{
    public function list()
    {
        $body = Request::post();
        $query = SysAccount::createQuery($body);
        $list= CamlHump::toCamlArray($query->select());
        return ResposeUtils::ok(
            $list ,
            200,
            $query->count()
        );
    }
    function getbyid()
    {
        $id = Request::get("id");
        $one = SysAccount::findOne($id);
        return ResposeUtils::ok(
            $one
        );
    }
    function update()
    {
        $body = Request::post();
        $updateersuilt=SysAccount::updatePlus($body,$body['id']);
        return ResposeUtils::ok(
            $updateersuilt['id']
        );
    }
    function add()
    {
        $body = Request::post();
        $result=SysAccount::addPlus($body);
        return ResposeUtils::ok(
            $result['id']
        );
    }
    function delbyid()
    {
        $id = Request::get('id');
        $result=SysAccount::destroy($id);
        return ResposeUtils::ok(
            $result
        );
    }
}